<#include '/common/header.html' />
<link rel="stylesheet" type="text/css" href="${ctx}/themes/kaben/groupbuy/css/home_group.css" />
<script src="${ctx}/themes/kaben/groupbuy/js/groupbuy.js" type="text/javascript"></script>
<!-- 团购活动 -->
<#assign groupBuyActTag=newTag("groupBuyActTag")>
<#assign groupBuyAct=groupBuyActTag("{'act_id':${act_id} }")>

<!-- 团购标签 -->
<#assign groupBuyTag=newTag("groupBuyTag")>
<#assign groupBuy=groupBuyTag("{'goodsid':${goodsid}}")>

<!-- 获取商品列表标签 -->
<#assign goodsListTag = newTag("goodsListTag")>
<#assign goodsList=goodsListTag("'tagid':'12','goodsnum':'5'")>
<!-- 团购时间 -->
<#assign groupBuyActSurplusTag=newTag("groupBuyActSurplusTag")>
<#assign groupBuyActSurplus=groupBuyActSurplusTag("{'end_time':${groupBuyAct.end_time} }")>
<div class="clear"></div>
<div class="group_itle" >
	<div class="breadcrumb wrapper" >
		<span><a href="${ctx}/index.html">首页</a></span>
		<span class="arrow">&gt;</span>
		<span>团购</span>
	</div>
</div>
<div class="clear"></div>
<div class="group_goods_detail_outside" style="background:#fff;overflow:hidden;">
<div class="group_goods_detail">
	<div class="group_detail_left">
		<!-- 团购详细介绍 -->
		<div class="groupbuy_goods_intro">
			  <h2>${groupBuy.gb_name}</h2>
		      <h3>${groupBuy.gb_title!''}</h3>
		      <div class="groupbuy_intro_important">
		      	<div class="important_left">
		      		<div class="important_left_price">
		      			<#if groupBuyAct.act_status==2>
			      			<div class="close">
		          				已经结束
		          			</div>
	          			</#if>
	          			<#if groupBuyAct.act_status==1>
          				<div class="button">
	          				<span>￥<em>${groupBuy.price}</em></span>
	          				<#if groupBuy.goods_num==0>
								<a href="">已售罄</a>
	          					<#else>
	          					<a href="javascript:void(0);" class="addcart" onclick="addGoods()">我要团</a>
	          				</#if>
          				</div>
          			</#if>
	          		</div>
					<div class="groupbuy_info_left">
						<div class="prices">
							<dl>
								<dt>市场价</dt>
								<dd>
									<del>${groupBuy.original_price}</del>
								</dd>
							</dl>
							<dl>
								<dt>折扣</dt>
								<dd>
									<em>${groupBuy.price/groupBuy.original_price*10}折</em>
								</dd>
							</dl>
							<dl>
								<dt>节省</dt>
								<dd>
									<em>￥${groupBuy.original_price-groupBuy.price}</em>
								</dd>
							</dl>
						</div>
						<div class="trim"></div>
						<div class="require">
							<#if groupBuy.gb_status!=0>
								<h4>
									本商品已被团购 <em>${groupBuy.buy_num+groupBuy.visual_num}</em>件
								</h4>
							</#if>
							<#if groupBuy.gb_status==2>
								<p>团购活动已经结束</p>
							</#if>
						</div>
						<div class="time">
							<!-- 倒计时 距离本期结束 -->
							团购剩余时间： <span id="d1"></span><strong>天</strong> <span id="h1"></span><strong>小时</strong>
							<span id="m1"></span><strong>分</strong> <span id="s1"></span><strong>秒</strong>

							<script type="text/javascript">
								tms[tms.length] = "${groupBuyActSurplus.cha}";
								day[day.length] = "d1";
								hour[hour.length] = "h1";
								minute[minute.length] = "m1";
								second[second.length] = "s1";
							</script>
						</div>
					</div>
				</div>
		      	<div class="important_right">
		      		<@image border="0" src="${groupBuy.img_url!''}"  alt="${groupBuy.gb_name!''}" />
		      	</div>
		      </div>
		</div>
		<!-- 商品信息、商品评价 -->
		<div class="groupbuy_detail_tab">
			<div class="groupbuy_detail_tab_title">
				<ul>
					<li id="info" class="selected">
						<a href="javascript:void(0);">商品信息</a>
					</li>
					<li id="transaction" class="">
						<a href="javascript:void(0);">他们已经买了</a>
					</li>
				</ul>
			</div>
			<div class="groupbuy_detail_tab_contont">
				<div class="groupbuy_detail_tab_info">
					${groupBuy.remark!''} 
				</div>
				<div class="groupbuy_detail_tab_data" style="display:none">
							    <!-- 成交记录标签 -->
				<#assign recordListTag = newTag("recordListTag")>
				<!--调取"成交记录"标签，并传递参数,获取Page对象-->
				<#assign recordList = recordListTag("{'goods_id':${groupBuy.goods_id},'pageSize':20}")>
				<table class="g_record t_goods" cellspacing="0" cellpadding="0">
					<#if recordList.totalCount != 0 >
						<tr>
							<th class="w300">买家</th>
							<th class="w200">价格</th>
							<th class="w200">数量</th>
							<th class="w300">付款日期</th>
						</tr>
						<#list recordList.result as record>  
							<tr>
								<td>${record.uname}</td>
								<td class="goods_p">${record.price}</td>
								<td>${record.goods_num!'0'}</td>
								<td><@dateformat time="${record.rog_time?c}" pattern="yyyy-MM-dd HH:mm"/></td>
							</tr>
						</#list>
					<#else>
						 <tr><td  style="width:100%;height:30px;line-height:30px;">暂无购买记录。</td></tr> 
					</#if>
				</table>
				<div class="goods_page">
					<@ajaxpager  pageno="${recordList.currentPageNo}" pagesize="${recordList.pageSize}" totalcount="${recordList.totalCount}" />
				</div>
				</div>
			</div>
		</div>
	</div>
	<!-- 店铺信息、推荐团购 -->
	<div class="group_detail_right">
		<!-- 热门团购 -->
		<div class="groupbuy_hot_list">
			<h1>热门团购</h1>
			<div class="groupbuy_hot_list_all">
				<#list goodsList as goods>
					<dl>
						<!--商品图片-->
						<dd class="groupbuy_hot_img">
							<a target="_blank" href="${ctx}/goods.html?goodsid=${goods.goods_id}&gbid=${gbid}"> 
								<@image class="scrollLoading" src="${goods.thumbnail!''}" alt="${goods.name}" /> </a>
						</dd>
						<!--商品名称-->
						<dd class="groupbuy_hot_name">
							<a target="_blank" href="${ctx}/goods.html?goodsid=${goods.goods_id}&gbid=${gbid}" title="${goods.name}">${goods.name}</a>
						</dd>
						<dd class="groupbuy_hot_item">
							<span class="price">商城价：${goods.price?string.currency}</span>
							<a target="_blank" href="${ctx}/goods.html?goodsid=${goods.goods_id}&gbid=${gbid}" title="${goods.name}">抢购</a>
						</dd>
					</dl>
				</#list>
			</div>
		</div>
	</div>
</div>
</div>


<script>
	$(function(){
		$("#info").click(function(){
			$(".groupbuy_detail_tab_title ul li").removeClass("selected");
			$(this).addClass("selected");
			$(".groupbuy_detail_tab_info").show();
			$(".groupbuy_detail_tab_data").hide();
		})
		$("#transaction").click(function(){
			$(".groupbuy_detail_tab_title ul li").removeClass("selected");
			$(this).addClass("selected");
			$(".groupbuy_detail_tab_info").hide();
			$(".groupbuy_detail_tab_data").show();
		})
	})
	function addGoods(){ 
		$.Loading.show("请稍候...");
	    $.ajax({
			url:'${ctx}/api/groupbuy/cart/add-goods.do?goodsid=${groupBuy.goods_id}',
			data:{'num':1},
			dataType:"json",
			cache: false,             //清楚缓存，暂时测试，如果产生冲突，请优先考虑是否是这条语句。
			success:function(result){
				$.Loading.hide();
				if(result.result==1){
					location.href="../cart.html";
				}else{
					$.dialog({title:'提示',content: "发生错误:"+result.message,lock: true});
				}
				btn.attr("disabled",false);
			},
			error:function(){
				$.Loading.hide();
				$.dialog({title:'提示',content: "抱歉,发生错误",lock: true});
				btn.attr("disabled",false);
			}
		});
	}
</script>	
<!-----footer------>
<#include '/common/footer.html'/>